﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _01_委托必要性_示例
{
    public delegate void SetLabelTextDelegate(string text);

    public partial class Form1 : Form
    {
        //委托对象
        public static SetLabelTextDelegate SetLabe=null;

        public Form1()
        {
            InitializeComponent();
            //绑定委托对应的方法
            SetLabe = new SetLabelTextDelegate(SetLabelText);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            new Form2().Show();
        }

        public void SetLabelText(string text)
        {
            this.label1.Text = text;
        }

    }
}
